package com.feng.gaoerfu.bean;

/**
 * @time 2017/9/13 0013 21:51
 */

public class ContactPerson implements Comparable<ContactPerson>{

    public String name;
    public String PhoneNumber;
    private String mPinyin;
    private char firstChar;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhoneNumber() {
        return PhoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        PhoneNumber = phoneNumber;
    }

    public void setPinyin(String pinyin) {
        mPinyin = pinyin;
        String first = pinyin.substring(0, 1);
        if (first.matches("[A-Za-z]")) {
            firstChar = first.toUpperCase().charAt(0);
        } else {
            firstChar = '#';
        }
    }

    public String getPinyin() {
        return mPinyin;
    }

    @Override
    public int compareTo(ContactPerson another) {
        return this.mPinyin.compareTo(another.getPinyin());
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof ContactPerson) {
            return this.name == ((ContactPerson) o).getName();
        } else {
            return super.equals(o);
        }
    }

    public char getFirstChar() {
        return firstChar;
    }
}
